<%@ page language="java" import="java.util.*" pageEncoding="utf-8" contentType="text/html;charset=utf-8"%>
<% request.setCharacterEncoding("utf-8"); %>
<%@ taglib prefix="c" uri="/WEB-INF/c.tld" %>
<%@ taglib prefix="fmt" uri="/WEB-INF/fmt.tld" %>
<c:if test="${adminList==null}">
	<c:redirect url="/servlet/UserManageServlet?fromPage=/Admin/Admin_List.jsp&act=adminList"></c:redirect>
</c:if>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>Shop 管理中心 - 管理员列表</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<link href="<c:url value="/Admin/styles/general.css" />" rel="stylesheet" type="text/css" />
	<link href="<c:url value="/Admin/styles/main.css" />" rel="stylesheet" type="text/css" />
	<script language="javascript">
		function pagingOnClick(num){
			if(num==1){
				searchForm.curPage.value=1;
			}
			if(num==2){
				searchForm.curPage.value=${curPage} - 1;
			}
			if(num==3){
				searchForm.curPage.value=${curPage} + 1;
			}
			if(num==4){
				searchForm.curPage.value=${pageCount};
			}
				searchForm.submit();
		}
		
		function confirm_redirect(suser) {
			if (confirm("您确定要删除该管理员账号吗?")) {
				if(suser != "admin") {
					location.href="<c:url value='/servlet/UserManageServlet?fromPage=/Admin/Admin_List.jsp&del=" + suser + "&act=deladmin' />"
				} else {
					alert("超级管理员admin不能删除！");
				}
			}
		}
		
		function showinfo(suser) {
			location.href="<c:url value='/Admin/Admin_Info.jsp?suser=" + suser+"' />";
		}
		function editinfo(suser) {
			location.href="<c:url value='/Admin/Admin_Einfo.jsp?suser=" + suser+"' />";
		}
		function editpwd(suser) {
			location.href="<c:url value='/Admin/Admin_Epwd.jsp?suser=" + suser+"' />";
		}
	</script>
  </head>
  
  <body> 
    <h1>
		<span class="action-span"><a href="<c:url value="/Admin/Admin_Add.jsp" />">添加管理员</a></span>
		<span><a href="<c:url value='/Admin/Admin_Main.jsp ' />">Shop 管理中心</a> - 管理员列表 </span>
	</h1>
	<div class="form-div">
	  <form action="<c:url value="/servlet/UserManageServlet"/>" name="searchForm">
	    <img src="<c:url value="/Admin/images/icon_search.gif" />" width="26" height="22" border="0" alt="SEARCH" />
	    &nbsp;管理员用户名 &nbsp;<input type="text" name="suser" value="${param.suser}" /> 
	    &nbsp;管理员真实姓名 &nbsp;<input type="text" name="sname" value="${param.sname}" />&nbsp;
	    <input type="submit" value=" 搜索 " class="button" />
	    <input type="hidden" name="act" value="adminList" />
	    <input type="hidden" name="fromPage" value="/Admin/Admin_List.jsp" />
	    <input type="hidden" name="curPage" value="1" />
	  </form>
	</div>
	<div class="list-div" id="listDiv">
		<!--用户列表部分-->
		<table cellpadding="0" cellspacing="1">
		  <tr>
		    <th>用户名</th>
		    <th>真实姓名</th>
		    <th>邮件地址</th>
		    <th>电话号码</th>
		    <th>管理员等级</th>
		    <th>最后登陆时间</th>
		    <th>操作</th>
		  </tr>
		  <c:forEach var="userBean" items="${adminList}">
			  <c:if test="${userBean.nlevel ne 9}">
			    <tr>
			    <td align="center">${userBean.suser}</td>
			    <td align="center">${userBean.sname}</td>
			    <td align="center">${userBean.semail}</td>
			    <td align="center">${userBean.sphone}</td>
			    <c:choose>
			    <c:when test="${userBean.nlevel eq 1}">
			        <td align="center">超级管理员</td>
			    </c:when>
			    <c:when test="${userBean.nlevel eq 5}">
			        <td align="center">普通管理员</td>
			    </c:when>
			    </c:choose>
			    <td align="center">${userBean.dlastdate}</td>
			    <td align="center">
			    	<span onclick="showinfo('${userBean.suser}');" style="cursor:hand;" title="查看管理员资料">
			        <img src="<c:url value="/Admin/images/icon_view.gif"/>" border="0" height="16" width="16" /></span>
			    	<span onclick="editinfo('${userBean.suser}');" style="cursor:hand;" title="编辑管理员资料">
			        <img src="<c:url value="/Admin/images/icon_edit.gif"/>" border="0" height="16" width="16" /></span>
			        <span onclick="editpwd('${userBean.suser}');" style="cursor:hand;" title="修改管理员密码">
			        <img src="<c:url value="/Admin/images/book_open.gif"/>" border="0" height="16" width="16" /></span>
			    	<span onclick="confirm_redirect('${userBean.suser}');" style="cursor:hand;" title="删除管理员">
			        <img src="<c:url value="/Admin/images/icon_drop.gif"/>" border="0" height="16" width="16" /></span>
			    </td>
			 	</tr>
			  </c:if>
		  </c:forEach>
		    <tr>
		      <td align="right" nowrap="true" colspan="7" height="22px">
		         <div id="turn-page">
		        总计  <span id="totalRecords">${recordSize}</span>
		        个记录&nbsp;分为 <span id="totalPages">${pageCount}</span>
		        页&nbsp;当前第 <span id="pageCurrent">${curPage}</span>
		        页 
		        <span id="page-link">
		        <c:choose>
				<c:when test="${curPage==1}">
				<span>首页</span>
				<span>上一页</span>
				</c:when>
				<c:otherwise>
				<a href="#" onClick="pagingOnClick(1);return false;" >首页</a>
				<a href="#" onClick="pagingOnClick(2);return false;" >上一页</a>
				</c:otherwise>
				</c:choose>
				<c:choose>
				<c:when test="${curPage==pageCount}">
				<span>下一页</span>
				<span>尾页</span>
				</c:when>
				<c:otherwise>
				<a href="#" onClick="pagingOnClick(3);return false;" >下一页</a>
				<a href="#" onClick="pagingOnClick(4);return false;" >尾 页</a>
				</c:otherwise>
				</c:choose>
		        </span>
		        </div>
		     </td>
		  </tr>
		</table>
	</div>
	<div id="footer">版权所有 &copy;</div>
	<c:if test="${not empty param.msg}">
	<script type="text/javascript" language="javascript">
		alert("${param.msg}");
		location.href="<c:url value='/Admin/Admin_List.jsp'/>";
	</script>
	</c:if>
  </body>
</html>
